﻿using OverStore.Runtime;
using OverStore.Runtime.Logger;
using OverStore.Runtime.OverStoreContext;
using OverStore.Runtime.Storage;
using OverStore.Runtime.PersistenceServiceProvider;
using OverStore.Scoping.Manager;

namespace OverStore.TutorialAsTest.UnitTest.Configuration.Mocks
{
    public class MockContext : IOverStoreContext
    {
        private readonly OperationScopeManager scopeManagerValue = new OperationScopeManager();

        public MockContext(IDataStorage dataSource)
        {
            Logger = ConsoleLogger.Value;
            Provider = new MockPersistenceServiceProvider();
            PersistenceServiceProvider = new DefaultRegistryLocator();
        }

        public MockContext()
            : this(new MockAdoNetDataSource())
        { }

        public IPersistenceSession CurrentSession
        {
            get;
            set;
        }

        public void SetCurrentSession(IPersistenceSession currentSession)
        {
            CurrentSession = currentSession;
        }

        public IPersistenceServiceProvider Provider
        {
            get;
            set;
        }

        public void SetPersistenceServiceProvider(IPersistenceServiceProvider provider)
        {
            Provider = provider;
        }

        public IDataStorage DataStorage
        {
            get;
            set;
        }

        public ILogger Logger
        {
            get;
            set;
        }

        public IPersistenceServiceProvider PersistenceServiceProvider
        {
            get;
            set;
        }

        public OperationScopeManager ScopeManager
        { get { return scopeManagerValue; } }
    }
}
